#pragma once
#include <string>
#include "Keypad.h"
#include "Display.h"
#include "Mouse.h"
#include <opencv2/opencv.hpp>
using std::wstring;

class KmdHost
{
public:
    KmdHost();
    ~KmdHost();

public:
    virtual long BindWindow(long hwnd, const wstring &sdisplay, const wstring &smouse, const wstring &skeypad, long mode);
    virtual long UnBindWindow();
    virtual long GetBindWindow();
    virtual long IsBind();
    // virtual long GetCursorPos(int& x, int& y);
    virtual long ResetWindow(long hwnd);

    long GetDisplay();
    /*byte* GetScreenData();*/
    long get_height();
    long get_width();
    long RectConvert(long &x1, long &y1, long &x2, long &y2);
    // 0:normal;-1 reserve 1 need cut
    long get_image_type();

    bool check_bind();
    const std::pair<wstring, wstring> &get_display_method() const;
    long set_display_method(const wstring &method);

    bool requestCapture(int x1, int y1, int w, int h, cv::Mat &img);

    long getHwnd() { return _hwnd; }

private:
    long _hwnd;
    int _is_bind;
    int _display;
    int _mode;
    std::pair<wstring, wstring> _display_method;
    cv::Mat _pic;

    Display *createDisplay(int mode);
    Mouse *createMouse(int mode);
    Keypad *createKeypad(int mode);

public:
    Display *_pbkdisplay;
    Mouse *_bkmouse;
    Keypad *_keypad;
    wstring currPath_;
};